#coding: utf-8
class CulturalHeritage::CollectionPhoto < ActiveRecord::Base
  has_attached_file :photo
  
  #belongs_to :obj_collection, :class_name => 'CulturalHeritage::Collection',  :foreign_key => 'collection'
  #mount_uploader :photo, PhotoUploader

  validates :photo_file_name, :presence => {:message => "La foto es requerida"}
  default_scope where("deleted = 0")

  def self.count_collection_dependencies(id)
      return find(:all,:conditions=>["cultural_heritage_collection_photos.collection = ? and (cultural_heritage_collection_photos.deleted = ?) ",id,0],:select=>"count(*) as 'collection_photos'")[0].collection_photos.to_i
  end
end
